export default {
  /**
   * @description:  获取浅色值
   * @param {color} 16进制色值
   * @param {tint} 深浅程度
   * @return: 16进制色值
   */
  tintColor(color, tint) {
    color = color.replace('#', '');
    tint = Number((tint / 10).toFixed(2));
    let red = parseInt(color.slice(0, 2), 16);
    let green = parseInt(color.slice(2, 4), 16);
    let blue = parseInt(color.slice(4, 6), 16);
    if (tint === 0) {
      return [red, green, blue].join(',');
    } else {
      red += Math.round(tint * (255 - red));
      green += Math.round(tint * (255 - green));
      blue += Math.round(tint * (255 - blue));
      red = red.toString(16);
      green = green.toString(16);
      blue = blue.toString(16);
      return `#${red}${green}${blue}`;
    }
  },

  /**
   * @description:  获取深色值
   * @param {color} 16进制色值
   * @param {tint} 深浅程度
   * @return: 16进制色值
   */
  shadeColor(color, shade) {
    color = color.replace('#', '');
    shade = Number((shade / 10).toFixed(2));
    let red = parseInt(color.slice(0, 2), 16);
    let green = parseInt(color.slice(2, 4), 16);
    let blue = parseInt(color.slice(4, 6), 16);
    red = Math.round((1 - shade) * red);
    green = Math.round((1 - shade) * green);
    blue = Math.round((1 - shade) * blue);
    red = red.toString(16);
    green = green.toString(16);
    blue = blue.toString(16);
    return `#${red}${green}${blue}`;
  }
}